---
title: Start with an existing project
description: Add Nx to any existing project with a single command. Start with Nx Core and gradually adopt plugins, CI integrations, and other capabilities.
sidebar:
  order: 4
  label: Add to existing project
filter: 'type:Guides'
---

{% course_video src="https://youtu.be/3hW53b1IJ84" courseTitle="From PNPM Workspaces to Distributed CI" courseUrl="https://nx.dev/courses/pnpm-nx-next/lessons-01-nx-init" /%}

In many situations, you have an existing codebase and want to improve it with Nx using an **incremental adoption approach**.

Thanks to [Nx's modular architecture](/docs/getting-started/intro), you can start with just **Nx Core** and then gradually add [technology-specific plugins](/docs/technologies), [CI integrations](/docs/getting-started/nx-cloud), or other capabilities as your requirements evolve.

Getting started is remarkably simple. You can add Nx to any existing project with a single command:

```shell
nx@latest init
```

{% aside type="note" title="Global Installs" %}
Make sure you have [Nx installed globally](/docs/getting-started/installation) or use `npx` if you're in a JavaScript environment
{% /aside %}

Whether a monorepo, single project or something in between, `nx init` walks you through adding and configuring Nx. You can pick a minimal approach or detailed guided setup. At the end you'll have an Nx workspace ready for anything!

## Next Steps

After initializing Nx, you can [run tasks](/docs/features/run-tasks) with `nx <task> <project-name>` (e.g. `nx build myproject`) or run one or many tasks across all projects with `nx run-many -t <task1> <task2>`.

You can also explore your codebase using:

- `nx graph` to view an interactive graph
- `nx show projects` to see a list of all projects
- `nx show project <project-name>` to view an interactive project detailed view

### Update CI Configurations

Now that Nx is installed, you'll want to update CI configurations to leverage Nx. You can do this by changing previous commands to use `nx` instead.

For example, switching from `pnpm` commands to use `nx`

```diff
// .github/workflows/ci.yaml
-     - run: pnpm run -r build
-     - run: pnpm run -r test
+     - run: npx nx run-many -t test build
```

You can directly invoke `package.json` scripts with `nx` as well

```diff
// .github/workflows/ci.yaml
-     - run: npm run build
-     - run: npm run test
+     - run: npx nx build
+     - run: npx nx test
```

[View CI provider specific setups](/docs/guides/nx-cloud/setup-ci) to learn more.

### Nx Cloud

{% aside type="note" title="How do I know if I enabled Nx Cloud?" %}
Validate Nx Cloud is enabled by checking the `nx.json` file for `nxCloudId` property.
You can add Nx Cloud at any point by running the `nx connect` command.
{%/aside%}

After initializing Nx, you'll need to commit and push the changes to your repository.

Once your changes are pushed, you can finish setting up your workspace by clicking on the list printed to your terminal, or by visiting [Nx Cloud directly](https://cloud.nx.app/get-started?utm_source=nx.dev&utm_campaign=nx_init) and clicking _"Connect an existing Nx repository"_

To leverage Self Healing CI, you'll need to add the following to your CI configuration:

```diff
// .github/workflows/ci.yaml
      - run: npx nx run-many -t lint test build
+       # Enable Self Healing CI w/ Nx Cloud
+     - run: npx nx fix-ci
+       if: always()
```

### Empower Your Editor

Enhance your developer experience by using the Nx Console editor extension.

{% install_nx_console /%}

## In-depth Guides

Here are some guides that give you more details based on the technology stack you're using:

{% cardgrid %}

{% linkcard title="Add to Existing Monorepo"
href="/docs/guides/adopting-nx/adding-to-monorepo" %}
{% /linkcard %}
{% linkcard title="Add to Any Project"  href="/docs/guides/adopting-nx/adding-to-existing-project" /%}

{% linkcard title="Migrate from Angular CLI" href="/docs/technologies/angular/migration/angular" /%}

{% linkcard title="Import Projects into Your Nx Workspace" href="/docs/guides/adopting-nx/import-project" /%}

{% /cardgrid %}

{% linkcard title="See more options" href="/docs/guides/adopting-nx" /%}
